/* 热榜业务代码 */
import { ref, onMounted } from 'vue';
import { fetchHotGoodsAPI } from '@/apis/detail'
import { useRouter } from 'vue-router';

export function getHotGoods(type) {
    const router = useRouter()
    const goodsList = ref([])
    const HotDetail = ref({
        id: router.currentRoute.value.params.id,
        type: type,
    })
    const getWeekHotGoods = async () => {
        const { data: res } = await fetchHotGoodsAPI(HotDetail)
        goodsList.value = res.result
    }
    onMounted( () => getWeekHotGoods())

    return{
        goodsList
    }
}